<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>登录</title>
	<link rel="stylesheet" href="/static/css/bootstrap.min.css">
	<link rel="stylesheet" href="/static/css/public.css">
	<!-- jquery 提示插件css -->
	<link href="/static/plugins/toastr.min.css" rel="stylesheet">
	<style>
		body{
			width: 100%;
			height:100%;
			background: url("/static/image/logo.jpg") no-repeat;
			background-size:100% 100% ;
		}
		.formBox{
			width: 620px;
			position: absolute;
			bottom: 80px;
			right: 50%;
			margin-right: -310px;
		}
		input{
			width: 230px;
			height: 30px;
			border: none;
			padding-left: 10px;
			color: #777;
			font-size: 12px;
			margin-right: 30px;
			border-radius: 5px;
			float: left;
		}
		button{
			width: 100px;
			height: 36px;
			float: left;
		}
	</style>
</head>
<body>
<form class="formBox" id="logon_form"  action="/core/user/login/" method="POST">
	<input type="text" class="" placeholder="用户名" name="username">
	<input type="password" class="" placeholder="密码" name="password">
	<button type="button" class="btn btn-primary" onclick="logon()" >登录</button>
</form>

<!-- Toastr -->
<script src="/static/js/jquery.min.js?v=2.1.4"></script>
<!--vue-->
<script src="/static/js/vue.min.js"></script>
<script src="/static/plugins/toastr/toastr.min.js"></script>
<script src="/static/js/publicServe.js"></script>
<script src="/static/js/jquery.form.js"></script>
<script>
    //表单验证函数
    function logonEvent(){
        $("#logon_form").ajaxSubmit({
            success: function (response) {
                if(response.success==1){
                    localStorage.setItem('username',response.data[0].username);
                    localStorage.setItem('usertoken',response.data[0].token);
                    $(".user_token").val(response.data[0].token);
                    if(response.next!=null){
                        location.href = response.next;
                    }
                    else{
                        location.href='/';
                    }
                }
                else{
                    toastr.error(response.error_msg);
                }
            }
		})
    }
    //登录点击事件
    function logon() {
        logonEvent()
    }
    //回车事件
    document.onkeydown=function(event){
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(e && e.keyCode==13){
            logonEvent()
        }
    };
    //弹出框提示配置
    toastr.options = {
        "closeButton": true,
        "debug": false,
        "progressBar": true,
        "preventDuplicates": false,
        "positionClass": "toast-bottom-right",
        "onclick": null,
        "showDuration": "400",
        "hideDuration": "1000",
        "timeOut": "2000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    };
</script>
</body>
</html>